package com.zyl.message.util;

import io.netty.channel.Channel;

import java.util.HashMap;

/**
 * @Author PJW 2023/2/2 16:26
 */
public class UserChannelUtils {
    private static HashMap<Long, Channel> userChannelMap = new HashMap<>();

    /**
     * 添加客户端连接
     * @param userId 用户id
     * @param channel 连接对象
     */
    public static void put(Long userId,Channel channel){
        userChannelMap.put(userId, channel);
    }

    /**
     * 获取客户端连接
     * @param userId 用户id
     * @return Result
     */
    public static Channel get(Long userId){
        return userChannelMap.get(userId);
    }

    /**
     * 获取所有的客户端
     * @return Result
     */
    public static HashMap<Long, Channel> getAll(){
        return userChannelMap;
    }

}
